package core.ui.demo;

import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SplitMenuButton;
import javafx.scene.layout.VBox;
/**
 * @author 李瑜
 * @since JavaFX 8.0
 */
public class DemoMenuButton
{
	public static VBox getMenuButton()
	{
		VBox box = new VBox();
		box.setSpacing(5);
		ObservableList<Node> boxs = box.getChildren();
		
		MenuButton menuButton1 = new MenuButton("菜单按钮1");
		menuButton1.setPopupSide(Side.LEFT);
		ObservableList<MenuItem> list = menuButton1.getItems();
		list.add(new MenuItem("菜单1"));
		list.add(new MenuItem("菜单2"));
		
		MenuButton menuButton2 = new MenuButton("菜单按钮2");
		menuButton2.setPopupSide(Side.TOP);
		ObservableList<MenuItem> list2 = menuButton2.getItems();
		list2.add(new MenuItem("菜单1"));
		list2.add(new MenuItem("菜单2"));
		
		SplitMenuButton menuButton3 = new SplitMenuButton(
				new MenuItem[]
				{
					new MenuItem("菜单1"),
					new MenuItem("菜单2")
				});
		menuButton3.setPopupSide(Side.RIGHT);
		menuButton3.setText("分离菜单1");
		
		SplitMenuButton menuButton4 = new SplitMenuButton(
				new MenuItem[]
				{
					new MenuItem("菜单1"),
					new MenuItem("菜单2")
				});
		menuButton4.setPopupSide(Side.BOTTOM);
		menuButton4.setText("分离菜单2");
		
		boxs.add(menuButton1);
		boxs.add(menuButton2);
		boxs.add(menuButton3);
		boxs.add(menuButton4);
		
		return box;
	}
}
